﻿using System.Collections.Generic;
using ReagentStore.ERM;

namespace ReagentStore.UTL
{
	public static class RecordExtension
	{
		private static readonly Dictionary<string, string> _dictCaptions = new Dictionary<string, string>();

		static RecordExtension()
		{
			_dictCaptions.Add("IncomingRecord", "入库");
			_dictCaptions.Add("OutgoingRecord", "出库");
			_dictCaptions.Add("WearRecord", "损耗");
		}

		public static int Quantity(this Record record)
		{
			switch (record.GetType().Name)
			{
				case "IncomingRecord":
					return record.Count;

				case "OutgoingRecord":
				case "WearRecord":
					return record.Count*(-1);

				default:
					return 0;
			}
		}

		public static string Caption(this Record record)
		{
			return _dictCaptions[record.GetType().Name];
		}
	}
}